<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 
/**
 * getLastResponse
 *
 * Will return the last response date of the Project cancellation/dispute cases
 *
 * @access	private
 * @param	string
 * @return	string
 */
	function getLastResponse($caseId=NULL,$type='')
	{
		$CI 	=& get_instance();
		$mod 	= $CI->load->model('dispute_model');
		$conditions = array('project_cases.case_type' => $type);
		$orCondition = "(project_cases.id = '".$caseId."' or project_cases.parent = '".$caseId."')";
		$orderby = array('project_cases.created','DESC');
		$limit = array('1');
		
		$result = $CI->dispute_model->getProjectCases($conditions,$orCondition,'project_cases.created',$orderby,$limit);
		$data = $result->row();
		$timestamp = $data->created;
		if(date('d/M/Y') == date('d/M/Y',$timestamp))
		$date = $CI->lang->line('Today at')." ".date('H:i',$timestamp)." EST";
		else 
		$date = date('d-M-Y',$timestamp)." EST";		
		return $date;
	} //End of getBidsInfo function
	
	// ------------------------------------------------------------------------

	/**
	 * getAdminDetails
	 *
	 *
	 * @access	public
	 * @param	string
	 * @return	string
	 */
	function getAdminDetails($userId=NULL,$field='')
	{
		$CI 	=& get_instance();
		$mod 	= $CI->load->model('dispute_model');
		$conditions = array('admins.id'=>$userId);
		$fields = 'admins.'.$field;
		$result = $CI->dispute_model->getInfo('admins',$fields,$conditions);
		if($result->num_rows()>0)
		{
			$data = $result->row();
			$res = $data->$field;
		} else {
			$res = '';
		}
		return $res;	
	}//End of getAdminDetails function
	
	// ------------------------------------------------------------------------

	/**
	 * getUserDetails
	 *
	 * Create a admin URL based on the admin folder path mentioned in config file. Segments can be passed via the
	 * first parameter either as a string or an array.
	 *
	 * @access	public
	 * @param	string
	 * @return	string
	 */
	function getUserDetails($userId=NULL,$field='')
	{
		$CI 	=& get_instance();
		$mod 	= $CI->load->model('user_model');
		$conditions = array('users.id'=>$userId);
		$result = $CI->user_model->getUsers($conditions);
		if($result->num_rows()>0)
		{
			$data = $result->row();
			$res = $data->$field;
		} else {
			$res = '';
		}
		return $res;	
	}//End of getUserDetails function

	function getTotalProjectUserDone($programmer_id){
		$CI 	=& get_instance();
		$mod 	= $CI->load->model('user_model');
		$condition = array("projects.programmer_id" => $programmer_id);
		$result = $CI->user_model->getTotalProjectUserDone($condition);
		return $result;
	}

	function getTotalProjectClientDone($creator_id){
		$CI 	=& get_instance();
		$mod 	= $CI->load->model('user_model');
		$condition = array("projects.creator_id" => $creator_id);
		$result = $CI->user_model->getTotalProjectUserDone($condition);
		return $result;
	}

	function cutStringDes($string,$len){
		if($len > strlen($string)){$len=strlen($string);};
	    $pos = strpos($string, ' ', $len);
	    if($pos){$string = substr($string,0,$pos);}else{$string = substr($string,0,$len);}    
	    return $string;
	}
    function getCategoriesByGroup($group_id = null){
        $CI 	=& get_instance();
        $CI->load->model('skills_model');
        $conditions = array('categories.group_id' => $group_id,'categories.is_active' => 1,'categories.is_deleted' => 0);
        $fields = array('categories.id');
        $result = $CI->skills_model->getCategories($conditions,$fields);
        if($result->num_rows() > 0)
            return $result;
        else
            return false;
    }
    function cutString($string, $lenght = 100, $char = ''){
        if($string == ''){
            return '';
        }
        if($lenght > strlen($string)){
            return $string;
        }

        $string = strip_tags($string);
        $string = substr($string,0,$lenght);
        $string = strrev($string);
        $pos = strpos($string,' ');
        $string= substr($string,($pos + 1));
        $string=strrev($string);

        return $string.$char;
    }

    function getLogoGroup($id_group = NULL){
        $icon = array(
            19 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-apple'></span>
										<span class='grey'>iOS App</span>
									</div>",
                'border' => 'border'
                ,'hover' => 'grey-hover'
            ),
            20 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-android'></span>
										<span class='green'>Android App</span>
									</div>",
                'border' => 'border-green',
                'hover' => 'green-hover'
            ),
            21 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-winphone'></span>
										<span class='blue'>Window Phone App</span>
									</div>",
                'border' => 'border-blue',
                 'hover' => 'blue-hover'
            ),
            22 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-webapp'></span>
										<span class='white'>Web App</span>
									</div>",
                'border' => 'border-white',
                 'hover' => 'white-hover'
            ),
            26 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-design'></span>
										<span class='white'>Icon Design</span>
									</div>",
                'border' => 'border-white',
                'hover' => 'icon-hover'
            ),
            17 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-button'></span>
										<span class='grey'>Button Design</span>
									</div>",
                'border' => 'border',
                'hover' => 'button-hover'
            ),
            18 => array('icon' => "<div class='icon-item-content'>
										<span class='icon-marketing'></span>
										<span class='grey'>Marketing</span>
									</div>",
                'border' => 'border-white',
                'hover' => 'market-hover'
            ),
        );
        switch($id_group){
            case '19' :
                return $icon[$id_group];
                break;
            case '20' :
                return $icon[$id_group];
                break;
            case '21' :
                return $icon[$id_group];
                break;
            case '22' :
                return $icon[$id_group];
                break;
            case '26' :
                return $icon[$id_group];
                break;
            case '17' :
                return $icon[$id_group];
                break;
            case '18' :
                return $icon[$id_group];
                break;
            default:
                return $icon[20];
                break;
        }
    }

/* End of file users_helper.php */
/* Location: ./app/helpers/users_helper.php */
?>